package blogger

import (
	"bytes"
	"sync"
)

type BufferPool struct {
	pool *sync.Pool
}

func (b *BufferPool) Put(buf *bytes.Buffer) {
	b.pool.Put(buf)
}

func (b *BufferPool) Get() *bytes.Buffer {
	return b.pool.Get().(*bytes.Buffer)
}

func DefaultBufPool() *BufferPool {
	return &BufferPool{pool: &sync.Pool{
		New: func() any {
			return new(bytes.Buffer)
		},
	}}
}
